

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>Ceph 文件系统洗刷 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="处理占满的 Ceph 文件系统" href="../full/" />
    <link rel="prev" title="Ceph 文件系统客户端的驱逐" href="../eviction/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../">Ceph 文件系统</a> &raquo;</li>
        
      <li>Ceph 文件系统洗刷</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/cephfs/scrub.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id4">管理</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id5">挂载 CephFS</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id6">CephFS 内幕</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../eviction/"> 驱逐客户端</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> 洗刷</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">初始化文件系统洗刷</a></li>
<li class="toctree-l4"><a class="reference internal" href="#monitor-ongoing-file-system-scrubs">Monitor (ongoing) File System Scrubs</a></li>
<li class="toctree-l4"><a class="reference internal" href="#control-ongoing-file-system-scrubs">Control (ongoing) File System Scrubs</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../full/"> 文件系统占满的处理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../disaster-recovery-experts/"> 元数据修复</a></li>
<li class="toctree-l3"><a class="reference internal" href="../troubleshooting/"> 故障排除</a></li>
<li class="toctree-l3"><a class="reference internal" href="../disaster-recovery/"> 灾难恢复</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-journal-tool/"> cephfs-journal-tool</a></li>
<li class="toctree-l3"><a class="reference internal" href="../recover-fs-after-mon-store-loss/"> 监视器存储丢失后恢复文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../#id8">开发者指南</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="ceph">
<span id="mds-scrub"></span><h1>Ceph 文件系统洗刷<a class="headerlink" href="#ceph" title="Permalink to this headline">¶</a></h1>
<p>CephFS provides the cluster admin (operator) to check consistency of a file system
via a set of scrub commands. Scrub can be classified into two parts:</p>
<ol class="arabic simple">
<li><p>Forward Scrub: In which the scrub operation starts at the root of the file system
(or a sub directory) and looks at everything that can be touched in the hierarchy
to ensure consistency.</p></li>
<li><p>Backward Scrub: In which the scrub operation looks at every RADOS object in the
file system pools and maps it back to the file system hierarchy.</p></li>
</ol>
<p>This document details commands to initiate and control forward scrub (referred as
scrub thereafter).</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>CephFS forward scrubs are started and manipulated on rank 0. All scrub
commands must be directed at rank 0.</p>
</div>
<div class="section" id="id1">
<h2>初始化文件系统洗刷<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<p>To start a scrub operation for a directory tree use the following command:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.&lt;</span><span class="n">fsname</span><span class="o">&gt;</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">start</span> <span class="o">&lt;</span><span class="n">path</span><span class="o">&gt;</span> <span class="p">[</span><span class="n">scrubopts</span><span class="p">]</span> <span class="p">[</span><span class="n">tag</span><span class="p">]</span>
</pre></div>
</div>
<p>where <code class="docutils literal notranslate"><span class="pre">scrubopts</span></code> is a comma delimited list of <code class="docutils literal notranslate"><span class="pre">recursive</span></code>, <code class="docutils literal notranslate"><span class="pre">force</span></code>, or
<code class="docutils literal notranslate"><span class="pre">repair</span></code> and <code class="docutils literal notranslate"><span class="pre">tag</span></code> is an optional custom string tag (the default is a generated
UUID). An example command is:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">start</span> <span class="o">/</span> <span class="n">recursive</span>
<span class="p">{</span>
    <span class="s2">&quot;return_code&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;scrub_tag&quot;</span><span class="p">:</span> <span class="s2">&quot;6f0d204c-6cfd-4300-9e02-73f382fd23c1&quot;</span><span class="p">,</span>
    <span class="s2">&quot;mode&quot;</span><span class="p">:</span> <span class="s2">&quot;asynchronous&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Recursive scrub is asynchronous (as hinted by <cite>mode</cite> in the output above).
Asynchronous scrubs must be polled using <code class="docutils literal notranslate"><span class="pre">scrub</span> <span class="pre">status</span></code> to determine the
status.</p>
<p>The scrub tag is used to differentiate scrubs and also to mark each inode’s
first data object in the default data pool (where the backtrace information is
stored) with a <code class="docutils literal notranslate"><span class="pre">scrub_tag</span></code> extended attribute with the value of the tag. You
can verify an inode was scrubbed by looking at the extended attribute using the
RADOS utilities.</p>
<p>Scrubs work for multiple active MDS (multiple ranks). The scrub is managed by
rank 0 and distributed across MDS as appropriate.</p>
</div>
<div class="section" id="monitor-ongoing-file-system-scrubs">
<h2>Monitor (ongoing) File System Scrubs<a class="headerlink" href="#monitor-ongoing-file-system-scrubs" title="Permalink to this headline">¶</a></h2>
<p>Status of ongoing scrubs can be monitored and polled using in <cite>scrub status</cite>
command. This commands lists out ongoing scrubs (identified by the tag) along
with the path and options used to initiate the scrub:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">status</span>
<span class="p">{</span>
    <span class="s2">&quot;status&quot;</span><span class="p">:</span> <span class="s2">&quot;scrub active (85 inodes in the stack)&quot;</span><span class="p">,</span>
    <span class="s2">&quot;scrubs&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;6f0d204c-6cfd-4300-9e02-73f382fd23c1&quot;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s2">&quot;path&quot;</span><span class="p">:</span> <span class="s2">&quot;/&quot;</span><span class="p">,</span>
            <span class="s2">&quot;options&quot;</span><span class="p">:</span> <span class="s2">&quot;recursive&quot;</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p><cite>status</cite> shows the number of inodes that are scheduled to be scrubbed at any point in time,
hence, can change on subsequent <cite>scrub status</cite> invocations. Also, a high level summary of
scrub operation (which includes the operation state and paths on which scrub is triggered)
gets displayed in <cite>ceph status</cite>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">status</span>
<span class="p">[</span><span class="o">...</span><span class="p">]</span>

<span class="n">task</span> <span class="n">status</span><span class="p">:</span>
  <span class="n">scrub</span> <span class="n">status</span><span class="p">:</span>
      <span class="n">mds</span><span class="mf">.0</span><span class="p">:</span> <span class="n">active</span> <span class="p">[</span><span class="n">paths</span><span class="p">:</span><span class="o">/</span><span class="p">]</span>

<span class="p">[</span><span class="o">...</span><span class="p">]</span>
</pre></div>
</div>
<p>A scrub is complete when it no longer shows up in this list (although that may
change in future releases). Any damage will be reported via cluster health warnings.</p>
</div>
<div class="section" id="control-ongoing-file-system-scrubs">
<h2>Control (ongoing) File System Scrubs<a class="headerlink" href="#control-ongoing-file-system-scrubs" title="Permalink to this headline">¶</a></h2>
<ul>
<li><p>Pause: Pausing ongoing scrub operations results in no new or pending inodes being
scrubbed after in-flight RADOS ops (for the inodes that are currently being scrubbed)
finish:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">pause</span>
<span class="p">{</span>
    <span class="s2">&quot;return_code&quot;</span><span class="p">:</span> <span class="mi">0</span>
<span class="p">}</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">scrub</span> <span class="pre">status</span></code> after pausing reflects the paused state. At this point,
initiating new scrub operations (via <code class="docutils literal notranslate"><span class="pre">scrub</span> <span class="pre">start</span></code>) would just queue the
inode for scrub:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">status</span>
<span class="p">{</span>
    <span class="s2">&quot;status&quot;</span><span class="p">:</span> <span class="s2">&quot;PAUSED (66 inodes in the stack)&quot;</span><span class="p">,</span>
    <span class="s2">&quot;scrubs&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;6f0d204c-6cfd-4300-9e02-73f382fd23c1&quot;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s2">&quot;path&quot;</span><span class="p">:</span> <span class="s2">&quot;/&quot;</span><span class="p">,</span>
            <span class="s2">&quot;options&quot;</span><span class="p">:</span> <span class="s2">&quot;recursive&quot;</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>Resume: Resuming kick starts a paused scrub operation:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">resume</span>
<span class="p">{</span>
    <span class="s2">&quot;return_code&quot;</span><span class="p">:</span> <span class="mi">0</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>Abort: Aborting ongoing scrub operations removes pending inodes from the scrub
queue (thereby aborting the scrub) after in-flight RADOS ops (for the inodes that
are currently being scrubbed) finish:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">abort</span>
<span class="p">{</span>
    <span class="s2">&quot;return_code&quot;</span><span class="p">:</span> <span class="mi">0</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
</ul>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../full/" class="btn btn-neutral float-right" title="处理占满的 Ceph 文件系统" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../eviction/" class="btn btn-neutral float-left" title="Ceph 文件系统客户端的驱逐" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>